<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
    String contextPath = request.getContextPath();
%>
<html>
<head>
    <title>管理后台</title>
    <script src="<%=contextPath%>/static/jquery-3.2.1.min.js"></script>
    <script src="<%=contextPath%>/static/bootstrap/js/bootstrap.js"></script>
    <link href="<%=contextPath%>/static/bootstrap/css/bootstrap.css" rel="stylesheet"/>
    <link href="<%=contextPath%>/static/bootstrap/css/bootstrap-theme.css" rel="stylesheet"/>
    <link rel="shortcut icon" href="<%=contextPath%>/img/bitbug_favicon.ico" type="image/x-icon" />
</head>
<style>
    table{
        text-align: center;
    }
</style>
<%--${listPage}--%>
<body>

<div class="container">
    <div class="panel panel-default">
        <!-- Default panel contents -->
        <div class="panel-heading">
           <span>文章列表</span>
            <div style="float: right">

        <span> ${admin.userId}</span>
                <a href="/admin/loginout">退出</a>
            </div>
        </div>

        <div class="panel-body">
            <p>
                <a class="btn btn-primary btn-sm" href="/admin/write" role="button">新建博客</a>
                <a class="btn btn-primary btn-sm" href="" role="button">恢复删除</a>

            </p>
            <p>
               <span class="text-center">标题</span> <input class="input-sm" type="text">
               <span class="text-center">摘要</span> <input class="input-sm" type="text">
               <span class="text-center">时间</span> <input class="input-sm" type="datetime-local">
                <button>搜索</button>
            </p>
        </div>

        <table class="table">
            <tr class="info">
                <td>编号</td>
                <td>标题</td>
                <td>摘要</td>
                <td>时间</td>
                <td style="text-align: center" colspan="2">操作</td>
            </tr>


         <c:forEach begin="0" var="article" items="${listPage.list}" step="1">
                <tr>
                    <td>${article.id}</td>
                    <td>${article.title}</td>
                    <td>${article.summary}</td>
                    <td>${article.time}</td>
                    <td><a href="/admin/update/${article.id}">修改</a></td>
                    <td><a href="/admin/delete/${article.id}">删除</a></td>
                </tr>
            </c:forEach>
        </table>

    </div>
    <div class="text-center">
        <nav>
            <ul class="pagination">
                <li><a href="<c:url value="/admin/list?currentPage=1"/>">首页</a></li>
                <li><a href="<c:url value="/admin/list?currentPage=${listPage.totals/10-1>1?listPage.totals/10-1:1}"/>">&laquo;</a></li>

                <c:forEach begin="1" end="${listPage.totals/10}" varStatus="loop">
                    <c:set var="active" value="${loop.index==page?'active':''}"/>
                    <li class="${active}"><a
                            href="<c:url value="/admin/list?currentPage=${loop.index}"/>">${loop.index}</a>
                    </li>
                </c:forEach>
                <li>
                    <fmt:formatNumber var="currentPage" value="${listPage.totals/10+1<totalPages?listPage.totals/10+1:listPage.totals/10 +(1-(listPage.totals/10%1))%1}" type="number" pattern="#"/>

                    <a href="<c:url value="/admin/list?currentPage=${currentPage}"/>">&raquo;</a>
                </li>


                <fmt:formatNumber var="endPage" value="${listPage.totals/10+(1-(listPage.totals/10%1))%1}" type="number" pattern="#"/>

                <li><a href="<c:url value="/admin/list?currentPage=${endPage} "/>">尾页</a></li>

            </ul>
        </nav>
    </div>

</div>
</body>
</html>
